Skip to content

fix: handle spaces in process.execPath on Windows @W-23997746@ - #1388

Merged
k80bowman merged 6 commits into
mainfrom
wr/fixSpawnExecPathSpaces
Aug 27, 2026
Merged

fix: handle spaces in process.execPath on Windows @W-23997746@#1388
k80bowman merged 6 commits into
mainfrom
wr/fixSpawnExecPathSpaces

Conversation

@WillieRuemmele

Copy link
Copy Markdown
Contributor

Summary

  • Remove windowsVerbatimArguments: true from cpSpawn options — this flag prevented Node.js from properly escaping the executable path in the spawned command line
  • Remove manual quoting of the .js module path (no longer needed without verbatim mode)
  • On Windows, when Node.js is installed at a path with spaces (e.g. C:\Program Files\nodejs\node.exe), the unquoted process.execPath was split at the space by CreateProcessW's command-line parser, causing plugins:install/uninstall/update to fail with a misleading "does not exist in the registry" error

Fixes #1387

Work Item

@W-23997746@

Proof of Work

  • Tests: 33 passing (630ms)
  • Lint: clean
  • Type check: clean
  • Build: clean

Test plan

  • Existing tests pass (including spaces-in-script-path test)
  • New test: process.execPath symlinked to a path with spaces correctly spawns the .js module
  • Manual verification on Windows with Node.js at C:\Program Files\nodejs\ (requires Windows environment)

Use Node.js's argv0 spawn option to pass a quoted process.execPath
into the command line on Windows when the path contains spaces.
This separates executable resolution (unquoted path for
lpApplicationName) from command-line construction (quoted for correct
argv parsing in the child process).

Retains windowsVerbatimArguments to preserve the existing security
property of preventing argument injection.

Closes #1387
@WillieRuemmele
WillieRuemmele force-pushed the wr/fixSpawnExecPathSpaces branch from 2fee43c to c34c18e Compare August 26, 2026 14:41
WillieRuemmele and others added 5 commits August 26, 2026 08:48
Source-level assertion ensures windowsVerbatimArguments: true cannot
be removed without breaking tests (prevents P1 RCE regression).
Behavioral test verifies shell metacharacters are never interpreted.
- Use metacharacter payloads without spaces (windowsVerbatimArguments
  passes args verbatim so spaces cause CRT to split them)
- Skip bash-specific test on Windows (no shell association for
  extensionless scripts)
The `latest` node-version now resolves to Node 26.8.0-alpha on
GitHub Actions runners, which fails yarn's engine check. Use lts/*
(Node 22) to match the sf-integration-tests job.
symlinkSync requires elevated privileges on Windows CI runners.
The actual spaces-in-execPath behavior is validated by the passing
sf-integration-tests on Windows and the source-level assertion for
windowsVerbatimArguments.
@k80bowman
k80bowman merged commit cff2c7c into main Aug 27, 2026
16 checks passed
@k80bowman
k80bowman deleted the wr/fixSpawnExecPathSpaces branch August 27, 2026 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants